home *** CD-ROM | disk | FTP | other *** search
- SYNC(3C) Last changed: 1-13-99
-
-
- NNAAMMEE
- ssyynncc, ____ffeettcchh__aanndd__aadddd, ____ffeettcchh__aanndd__ssuubb, ____ffeettcchh__aanndd__oorr,
- ____ffeettcchh__aanndd__aanndd, ____ffeettcchh__aanndd__xxoorr, ____ffeettcchh__aanndd__nnaanndd, ____aadddd__aanndd__ffeettcchh,
- ____ssuubb__aanndd__ffeettcchh, ____oorr__aanndd__ffeettcchh, ____aanndd__aanndd__ffeettcchh, ____xxoorr__aanndd__ffeettcchh,
- ____nnaanndd__aanndd__ffeettcchh, ____ccoommppaarree__aanndd__sswwaapp, ____ssyynncchhrroonniizzee,
- ____lloocckk__tteesstt__aanndd__sseett, ____lloocckk__aaccqquuiirree, ____lloocckk__rreelleeaassee - C
- synchronization primitives for multiprocessing
-
- SSYYNNOOPPSSIISS
- See summaries in DESCRIPTION
-
- IIMMPPLLEEMMEENNTTAATTIIOONN
- IRIX systems
-
- DDEESSCCRRIIPPTTIIOONN
- The intrinsics described here provide a variety of primitive
- synchronization operations. Besides performing the particular
- synchronization operation, each of these intrinsics has two key
- properties:
-
- 1. The function performed is guaranteed to be atomic (typically
- achieved by implementing the operation using a sequence of load-
- linked/store-conditional instructions in a loop).
-
- 2. Associated with each instrinsic are certain memory barrier
- properties that restrict the movement of memory references to
- visible data across the intrinsic operation (by either the compiler
- or the processor).
-
- A visible memory reference is a reference to a data object
- potentially accessible by another thread executing in the same
- shared address space. A visible data object may be one of the
- following:
-
- * C/C++ global data
-
- * Fortran COMMON data
-
- * Data declared _e_x_t_e_r_n
-
- * Volatile data
-
- * Static data (either file-scope or function-scope)
-
- * Data accessible via function parameters
-
- * Automatic data (local-scope) that has had its address taken and
- assigned to some object which is visible (recursively)
-
- The memory barrier semantics of an intrinsic may be one of the
- following three types:
-
- aaccqquuiirree bbaarrrriieerr
- Disallows the movement of memory references to visible data from
- after the intrinsic (in program order) to before the intrinsic
- (this behavior is desirable at lock-acquire operations, hence the
- name).
-
- rreelleeaassee bbaarrrriieerr
- Disallows the movement of memory references to visible data from
- before the intrinsic (in program order) to after the intrinsic
- (this behavior is desirable at lock-release operations, hence the
- name).
-
- ffuullll bbaarrrriieerr
- disallows the movement of memory references to visible data past
- the intrinsic (in either direction), and is thus both an acquire
- and a release barrier. A barrier only restricts the movement of
- memory references to visible data across the intrinsic operation:
- between synchronization operations (or in their absence), memory
- references to visible data may be freely reordered subject to the
- usual data-dependence constraints.
-
- CCaauuttiioonn:: Conditional execution of a synchronization intrinsic (such as
- within a iiff or a wwhhiillee statement) does not prevent the movement of
- memory references to visible data past the overall iiff or wwhhiillee
- construct.
-
- AAttoommiicc ffeettcchh--aanndd--oopp OOppeerraattiioonnss
- "type __fetch_and_add (type* ptr, type value, ...)"
-
- "type __fetch_and_sub (type* ptr, type value, ...)"
-
- "type __fetch_and_or (type* ptr, type value, ...)"
-
- "type __fetch_and_and (type* ptr, type value, ...)"
-
- "type __fetch_and_xor (type* ptr, type value, ...)"
-
- "type __fetch_and_nand(type* ptr, type value, ...)"
-
- Where ttyyppee may be one of iinntt, lloonngg, lloonngg lloonngg, uunnssiiggnneedd iinntt, uunnssiiggnneedd
- lloonngg, or uunnssiiggnneedd lloonngg lloonngg. The ellipses (...) refers to an optional
- list of variables protected by the memory barrier.
-
- Behavior:
-
- * Atomically performs the specified operation with the given value on
- **ppttrr, and returns the old value of **ppttrr, as in the following
- example:
-
- { tmp = *ptr; *ptr <op>= value; return tmp; }
-
- * Full barrier.
-
- AAttoommiicc oopp--aanndd--ffeettcchh OOppeerraattiioonnss
- "type __add_and_fetch (type* ptr, type value, ...)"
-
- "type __sub_and_fetch (type* ptr, type value, ...)"
-
- "type __or_and_fetch (type* ptr, type value, ...)"
-
- "type __and_and_fetch (type* ptr, type value, ...)"
-
- "type __xor_and_fetch (type* ptr, type value, ...)"
-
- "type __nand_and_fetch(type* ptr, type value, ...)"
-
- Where ttyyppee may be one of iinntt, lloonngg, lloonngg lloonngg, uunnssiiggnneedd iinntt, uunnssiiggnneedd
- lloonngg, or uunnssiiggnneedd lloonngg lloonngg. The ellipses (...) refers to an optional
- list of variables protected by the memory barrier.
-
- Behavior:
-
- * Atomically performs the specified operation with the given value on
- *ptr, and returns the new value of *ptr. (i.e.)
-
- { *ptr <op>= value; return *ptr; }
-
- * Full barrier.
-
- AAttoommiicc ccoommppaarree--aanndd--sswwaapp OOppeerraattiioonn
- "int __compare_and_swap (type* ptr, type oldvalue, type newvalue, ...)"
-
- Where ttyyppee may be one of iinntt, lloonngg, lloonngg lloonngg, uunnssiiggnneedd iinntt, uunnssiiggnneedd
- lloonngg, or uunnssiiggnneedd lloonngg lloonngg. The ellipses (...) refers to an optional
- list of variables protected by the memory barrier.
-
- Behavior:
-
- * Atomically do the following: compare *ptr to oldvalue. If equal,
- store the new value and return 1, otherwise return 0. (i.e.)
-
- if (*ptr != oldvalue) return 0;
-
- else {
-
- *ptr = newvalue;
-
- return 1;
- }
-
- * Full barrier.
-
- AAttoommiicc ssyynncchhrroonniizzee OOppeerraattiioonn
- "__synchronize (...)"
-
- The ellipses (...) refers to an optional list of variables protected
- by the memory barrier.
-
- Behavior:
-
- * Full barrier
-
- AAttoommiicc lloocckk--tteesstt--aanndd--sseett OOppeerraattiioonn
- ""ttyyppee ____lloocckk__tteesstt__aanndd__sseett ((ttyyppee** ppttrr,, ttyyppee vvaalluuee,, ......))""
-
- Where ttyyppee may be one of iinntt, lloonngg, lloonngg lloonngg, uunnssiiggnneedd iinntt, uunnssiiggnneedd
- lloonngg, or uunnssiiggnneedd lloonngg lloonngg. The ellipses (...) refers to an optional
- list of variables protected by the memory barrier.
-
- Behavior:
-
- * Atomically store the supplied value in *ptr and return the old value
- of *ptr. (i.e.)
-
- { tmp = *ptr; *ptr = value; return tmp; }
-
- * Acquire barrier.
-
- AAttoommiicc lloocckk__rreelleeaassee OOppeerraattiioonn
- "void __lock_release (type* ptr, ...)"
-
- Where ttyyppee may be one of iinntt, lloonngg, lloonngg lloonngg, uunnssiiggnneedd iinntt, uunnssiiggnneedd
- lloonngg, or uunnssiiggnneedd lloonngg lloonngg. The ellipses (...) refers to an optional
- list of variables protected by the memory barrier.
-
- Behavior:
-
- * Set *ptr to 0. (i.e.) { *ptr = 0 }
-
- * Release barrier.
-
- SSEEEE AALLSSOO
- This man page is available only online.
-